Einhugur Xml Serialization Framework for Einhugur Xml Plugin

XmlSerializer.DeSerialize Method

De-serialises a class structure, adding also Array of known classes to support de-serializing polymorphic structures.

shared DeSerialize(
   item as Object,
   rootName as String,
   xmlDoc as EinhugurXml.Document,
   knownClasses() as Introspection.TypeInfo)

Parameters

item
The object to de-serialize into
rootName
Name of the root.
xmlDoc
The Xml Document to be de-serialized.
knownClasses()
Array of known classes.

Remarks

You need to use this method when your class interface does not tell the whole story about the objects it contains.

For example if you have property like

Item as Vehicle

But the actual data your putting in that property is Truck or Motorcycle, both of which inherit from Vehicle class, then you need to add Truck and Motorcycle as known classes since the serializer will not be able to get their class info from your class interface.


All classes that are de-serialized must have a default constructor that has no parameters.

In this example here we needed to add Customer and Address as known types as they were serialized as Polymorphic objects instead of strongly typed.


var deserializedFacility as Facility = new Facility()

var knownClasses() as Introspection.TypeInfo
knownClasses.Add(GetTypeInfo(Address))
knownClasses.Add(GetTypeInfo(Customer))

XmlSerialization.XmlSerializer.DeSerialize(deserializedFacility,"Facility",xmlDoc, knownClasses)

See Also

XmlSerializer Class